﻿using System;
using NUnit.Framework;
using Smartkernel;
using Smartkernel.Extensions;

namespace Smartkernel.NUnitTest.Extensions
{
    [Category("Extensions")]
    [TestFixture]
    public class SmartDateTimeExtensionTest
    {
        [Test]
        public void Test()
        {
            //【01】格式化日期（涉及方法：ToString）
            DateTime birthDay = DateTime.Parse("1982-05-02");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYY), "1982");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYY_MM_DD), "1982-05-02");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYYMMDD), "19820502");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYY年MM月DD日), "1982年05月02日");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYY_MM), "1982-05");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.MM_DD), "05-02");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.MM月DD日), "05月02日");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.YYYY年MM月), "1982年05月");
            Assert.AreEqual(birthDay.ToString(SmartDateTimeFormatType.MMDD), "0502");
        }
    }
}
